<extend name="public@base5"/>
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('AdminAsset/index')}">{:lang('USER_ADMINASSET_INDEX')}</a>
            </li>
        </ul>
        <php>$statuses=[lang('Unavailable'), lang('Available')];</php>
        <table class="table table-hover table-bordered margin-top-20">
            <thead>
            <tr>
                <th width="50">ID</th>
                <th>{:lang('User')}</th>
                <th>{:lang('File size')}</th>
                <th>{:lang('File name')}</th>
                <th>{:lang('Thumbnail')}</th>
                <th>{:lang('File path')}</th>
                <th>{:lang('STATUS')}</th>
                <th width="60">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $asset_img_suffixes=['bmp','jpg','jpeg','png','gif','tiff'];/*TODO ADD MORE*/
            </php>
            <foreach name="assets" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>
                        ID:{$vo.user_id} {$vo.user_login} {$vo.user_nickname}
                    </td>
                    <td>{$vo.file_size/1024|round}KB</td>
                    <td>{$vo.filename}</td>
                    <td>
                        <if condition="in_array(strtolower($vo['suffix']),$asset_img_suffixes)">
                            <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo['file_path'])}');">
                                <i class="fa fa-photo fa-fw"></i>
                            </a>
                        </if>
                    </td>
                    <td>
                        {$vo.file_path}
                        <if condition="!file_exists('upload/'.$vo['file_path'])">
                            <span style='color:red;'>&nbsp;&nbsp({:lang('File missing')})</span>
                        </if>
                    </td>
                    <td>
                        {$statuses[$vo['status']]}
                    </td>
                    <td>
                        <a class="btn btn-xs btn-danger js-ajax-delete"
                           href="javascript:"
                           data-href="admin/assets/{$vo.id}" title="{:lang('DELETE')}" data-toggle="tooltip">
                            <i class="fa fa-trash fa-fw"></i>
                        </a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </div>
</block>
